import { ajax } from '../http.js';

const orderListUrl = '/authc/order/find_page';
const orderDetailUrl = '/authc/order/view';
const cancelOrderUrl = '/authc/order/cancel_order';
const OrderCostUrl = '/authc/postage/calculate_order_cost';
const logisticsUrl = '/authc/logistics_info/find_logistics';
const mainLogisticsUrl = '/authc/logistics_info/find_main_logistics';
const confirmOrderUrl = '/authc/order/confirm';
const deleteOrderUrl = '/authc/order/delete_order';


const orderList = (data, success, fail) => {
  ajax({
    noAuth: true,
    url: orderListUrl,
    data: data,
    success: success,
    fail: fail
  });
};
const orderDetail = (data, success, fail) => // 查看订单详情
  ajax({
    url: orderDetailUrl,
    data: data,
    success: success,
    fail: fail
  });
const cancelOrder = (data, success, fail) => // 待支付=>取消订单
  ajax({
    url: cancelOrderUrl,
    data: data,
    success: success,
    fail: fail
  });
const OrderCost = (data, success, fail) => // 主单获取折扣现金券
  ajax({
    url: OrderCostUrl,
    data: data,
    success: success,
    fail: fail
  });

const logistics = (data, success, fail) => // 获取物流信息
  ajax({
    url: logisticsUrl,
    data: data,
    success: success,
    fail: fail
  });
const mainLogistics = (data, success, fail) => // 获取物流信息
  ajax({
    url: mainLogisticsUrl,
    data: data,
    success: success,
    fail: fail
  });
const confirmOrder = (data, success, fail) => // 确认收获
  ajax({
    url: confirmOrderUrl,
    data: data,
    success: success,
    fail: fail
  });
const deleteOrder = (data, success, fail) => // 订单删除
  ajax({
    url: deleteOrderUrl,
    data: data,
    success: success,
    fail: fail
  });


export {
  orderList,
  orderDetail,
  cancelOrder,
  OrderCost,
  logistics,
  mainLogistics,
  confirmOrder,
  deleteOrder
};
